<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改用户')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-member-edit">
            <input name="userid" id="userid" th:value="${sysmember.userid}" type="hidden">
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">用户名(手机号)：</label>
                    <div class="col-sm-8">
                        <input name="username" th:value="${sysmember.username}" id="username" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">密码：</label>
                    <div class="col-sm-8">
                        <input name="password" class="form-control" type="password">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">昵称：</label>
                    <div class="col-sm-8">
                        <input name="nickname" th:value="${sysmember.nickname}"  class="form-control" type="text">
                    </div>
                </div>
            </div>

            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">积分：</label>
                    <div class="col-sm-8">
                        <input name="points" th:value="${sysmember.points}" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">余额：</label>
                    <div class="col-sm-8">
                        <input name="glods" th:value="${sysmember.glods}"  class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">用户组：</label>
                    <div class="col-sm-8">
                        <select name="group" class="form-control m-b" >
                            <option th:each="item : ${group}" th:text="${item.groupname}" th:selected="${sysmember.groupid}==${item.groupid}" th:value="${item.groupid}"></option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">vip用户组：</label>
                    <div class="col-sm-8">
                        <select name="vgroup" class="form-control m-b" >
                            <option value="0">请选择vip用户组</option>
                            <option th:each="item : ${vgroup}" th:selected="${sysmember.vgroupid}==${item.vgroupid}" th:text="${item.vgroupname}" th:value="${item.vgroupid}"></option>
                        </select>
                    </div>
                </div>
            </div>


            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">状态：</label>
                    <div class="col-sm-8">
                        <label class="toggle-switch switch-solid">
                            <input  id="state" type="checkbox"  th:checked="${sysmember.state == '0' ? false : true}">
                            <span></span>
                        </label>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "system/member";
        $("#form-member-edit").validate({
            onkeyup: false,
            rules:{
                nickname: "required",


                username:{
                    isPhone:true,
                    remote: {
                        url: prefix + "/checkPhoneUnique",
                        type: "post",
                        dataType: "json",
                        data: {
                            "userid": function() {
                                return $("#userid").val();
                            },
                            "username": function () {
                                return $.common.trim($("#username").val());
                            }
                        }
                    }
                },
            },
            messages: {
                "username":{
                    remote: "手机号码已经存在"
                }
            },
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                var data = $("#form-member-edit").serializeArray();
                var state = $("input[id='state']").is(':checked') == true ? 1 : 0;
                data.push({"name": "state", "value": state});
                $.operate.save(prefix + "/edit", data);
            }
        }


    </script>
</body>
</html>